package com.zjhome.cloudnote.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.zjhome.cloudnote.domain.DirInfo;
import com.zjhome.cloudnote.mapper.DirMapper;
import com.zjhome.cloudnote.param.DirPagingParam;
import com.zjhome.cloudnote.service.DirService;

@Service
public class DirServiceImpl implements DirService {
	@Autowired
	private DirMapper 	dirMapper;
	

	@Override
	public DirInfo selectDirById(String id, String uid) throws Exception {
		// 
		return dirMapper.selectDirById(id, uid);
	}

	@Override
	public List<DirInfo> selectSubDirsByDid(String did, String uid) throws Exception {
		// 
		return dirMapper.selectSubDirsByDid(did, uid);
	}

	@Override
	public int insertDirByParam(DirInfo dirInfo) throws Exception {
		//
		if (StringUtils.isEmpty(dirInfo.getId())) {
			dirInfo.setId(UUID.randomUUID().toString());
		}
		return dirMapper.insertDirByParam(dirInfo);
	}

	@Override
	public int updateDirByParam(DirInfo dirInfo) throws Exception {
		// 
		return dirMapper.updateDirByParam(dirInfo);
	}

	@Override
	public int deleteDirById(String id, String uid) throws Exception {
		// 
		return dirMapper.deleteDirById(id, uid);
	}

	@Override
	public List<DirInfo> selectDirsByParaPaging(DirPagingParam dirPagingParam) throws Exception {
		// 
		return dirMapper.selectDirsByParaPaging(dirPagingParam);
	}

	@Override
	public int selectDirsCountByPara(DirPagingParam dirPagingParam) throws Exception {
		// 
		return dirMapper.selectDirsCountByPara(dirPagingParam);
	}

	@Override
	public List<DirInfo> selectDirsByParam(DirInfo dirInfo) throws Exception {
		// 
		return dirMapper.selectDirsByParam(dirInfo);
	}

	@Override
	public List<DirInfo> selectDirTree(String pid, String uid) throws Exception {
		// 
		return dirMapper.selectDirTree(pid, uid);
	}

	@Override
	public int updateDirDelFlagByDir(String pid, String uid, int delflag) throws Exception {
		// 
		return dirMapper.updateDirDelFlagByDir(pid, uid, delflag);
	}

	@Override
	public int deleteSubDirById(String pid, String uid) throws Exception {
		// 
		return dirMapper.deleteSubDirById(pid, uid);
	}

}
